Force OpenGL states to be reset when RenderTarget detects that a new context has to be tracked. #1630
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1625.
Since the FBO
RenderTexture
implementation makes use of existing contexts where it can in order to reduce context switching,RenderTexture
s will almost always live in the same context as the context owningRenderTarget
s such assf::RenderWindow
. This also means that they will share the same OpenGL state. TheglStatesSet
flag that tracks whether OpenGL states have been set or not does so per-RenderTarget
.When (re-)creating a context the initial states required by SFML will have to be set up. This is normally done in
sf::RenderTarget::initialize()
when.create()
is called on the corresponding object. The problem is thatsf::RenderTarget::initialize()
is not called on the FBORenderTexture
s living on the same context as theRenderTarget
on which.create()
was called.As shown in #1625, drawing to an FBO
RenderTexture
directly after the window owning its context has been re-created will not reset the OpenGL states since the flag was never reset.This patch forces OpenGL states to be reset whenever the
RenderTarget
tracking detects a new context in which nothing has been activated before, regardless of whether it is aRenderWindow
or aRenderTexture
.Test with code provided in #1625.